<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>NovaCube - Accueil</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
	<!-- Optional theme -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
	<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  <!-- Font awesome pour les icones -->
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
	
</head>

<?php
include("bdd.php");

$query = mysqli_query($connexion, "SELECT `titre`FROM `articles` ORDER BY date DESC LIMIT 1");
$row = mysqli_num_rows($query);

if($row == null){
  $titre = "Aucun article";
  $article = "Il n'y a malheureusement encore aucun article ! C'est dommage ! :(";
  $date= "42/69";
  $auteur = "personne";
}else{
  $titre = current(mysqli_query($connexion, "SELECT `titre`FROM `articles` ORDER BY date DESC LIMIT 1")->fetch_assoc());
  $article = current(mysqli_query($connexion, "SELECT `corps`FROM `articles` ORDER BY date DESC LIMIT 1")->fetch_assoc());
  $auteur = current(mysqli_query($connexion, "SELECT `pseudo`FROM `articles` ORDER BY date DESC LIMIT 1")->fetch_assoc());
  $date = current(mysqli_query($connexion, "SELECT `date`FROM `articles` ORDER BY date DESC LIMIT 1")->fetch_assoc());
  $date = date('d/m/y', strtotime($date));
}

?>

<body style="background-image: url('fond.png');background-repeat: no-repeat;background-attachment: fixed;background-position: center;">
     
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href=""> NovaCube</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="index.php"><i class="fa fa-home"></i> Accueil</a></li>
        <li><a href="http://novacube.fr/forums"><i class="fa fa-comments"></i> Forum</a></li>
      </ul>

      <ul class="nav navbar-nav navbar-right">
        <li class="active"><a href="panel.php"><b>Pannel</b></a></li>
      </ul>
    </div>
  </div>
</nav>
    
<div class="container-fluid">
  <div class="row">
    <div class="col-md-1">
    </div>

    <div class="col-md-10">
      <div class="panel panel-default">
        <div class="panel-heading"><b><?php echo(htmlspecialchars_decode($titre." (écrit par ".$auteur. " le " .$date.")")); ?></b>
        </div>
        <div class="panel-body">
          <?php echo(htmlspecialchars_decode($article)); ?>
        </div>
      </div>
    </div>

    <div class="col-md-1">
    </div>
  </div>
</div>
</body>
</html>